import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import $ from 'jquery'
import coapi from './js/coapi.js'
import api from './utils/api.js'
import Mockjs from './utils/mock.js'
Vue.prototype.$api = api
Vue.use(iView);
import iView from 'iview';
import 'iview/dist/styles/iview.css';
Vue.use(iView);
Vue.config.productionTip = false


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app")

router.beforeEach((to, from, next) => {
     //console.log(to.meta.show)

  if (to.meta.requireAuth) {
    if (localStorage.getItem("islogin")) {
      next();
    } else {
      next({
        path: "/login"
      });
    }
  } else {
    next();
  }

  if (to.fullPath === "/login") {
     //console.log(to.meta.show)
    if (localStorage.getItem("islogin")) {
      next({
        path: from.fullPath
      });
    } else {
      next();
    }
  }
});